const { default: classNames } = require('classnames')
const _ = require('../utils')
const { inputBehavior, listItemBehavior, listParentBehavior } = require('../behaviors')

_.create('textarea', {
  properties: {
    rows: {
      type: [String, Number],
      value: 3,
    },
    fixed: Boolean,
    autoFocus: Boolean,
    autoHeight: Boolean,
    disableDefaultPadding: Boolean,
  },

  behaviors: [inputBehavior, listItemBehavior],

  computed: {
    classes(data) {
      const { classPrefix, inputFocus, error } = data
      const classes = classNames(classPrefix, {
        [`${classPrefix}-focus`]: inputFocus,
        [`${classPrefix}-error`]: error,
      })

      return classes
    },
  },

  relations: {
    listParent: {
      type: 'child',
      target: listParentBehavior,
    },
  },
})
